home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 18
/
018.d81
/
pps #40
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
193 lines
======================================
PEEKs, POKEs & SYSes, Part 40
by Jim Weiler and Alan Gardner
======================================
SOUND ON THE COMMODORE 64
-------------------------
This month we will begin to learn
how to make beautiful noises emanate
from our Commodore 64s. Now, don't
get all wild and frantic thinking
you'll be making music right away.
There are a lot of piddly details
involved in making Commodore 64
sound, and you have to know quite a
number of them before you can make
even the merest peep sound the way
you want it to.
We will cover ALL of those piddly
details in the coming months, delving
deeply into theories we never even
knew existed. With each installment
our knowledge will become more
complete until we know as much as the
pros think they do.
Enough big talk. Let's learn
something.
---
SID
---
SID stands for Sound Interface
Device. The SID is a single
integrated circuit that generates all
the sounds your Commodore makes.
Everything we learn about sound will
be based on the way SID works, so
let's start by looking briefly at how
we can talk to SID.
SID is always busy, even when
your computer isn't making a sound.
He's always checking 29 addresses to
see if there's anything for him to
do. SID makes noises based entirely
on what he finds in those addresses.
When you turn your computer on, those
addresses are set up to tell SID not
to make a peep. He keeps doing that
until you or your programs put values
in those addresses that say 'Start
Peeping'.
In fact, every sound your Commodore
has ever made (except gross physical
ones like the time you dropped it on
the floor) was made by SID following
instructions he found in his 29
address locations. Our coverage of
Commodore sound will deal almost
exclusively with the theory and
practice of putting the right data
into SID's addresses.
Oh yes, those addresses start at
54272. In most discussions from now
on I will set S=54272 and then use
offsets such as S+7 or S+24 to
indicate which SID address I am
using.
------------------
LET'S MAKE A NOISE
------------------
There's not a lot involved in
making SID make a noise. Let's
see... You need to decide how loud to
make it. Then you need to know what
pitch to use. You also need to know
what waveform and envelope to use.
(That's about like choosing an
instrument.) SID has three distinct
"voices" so you need to decide which
one to use. (They're all the same, so
it doesn't really matter which you
choose.) Finally, you need to decide
how long to make the noise.
Volume is one POKE. Pitch is two
more. Envelope takes two pokes, and
the waveform takes at least one to
turn the sound on and another to turn
it off. And you need some kind of a
delay loop for duration.
Here's an example of a simple
C-sharp tone.
S = 54272
POKE S+0,85:POKE S+1,36 (c-sharp)
POKE S+24,15 (volume)
POKE S+5,9:POKE S+6,0 (envelope)
POKE S+4,33 (play it)
FOR A=1 TO 200: NEXT (delay)
POKE S+4,32 (stop it)
You really can't make a satisfactory
sound on your own until you understand
envelope, waveform, volume, pitch, and
voice. So take a deep breath and
prepare for some heavy doses of
technical exposition.
------< continued in Part 41 >--------